package chatManagers;

//package wmmd.chat;
//package chatManagers;

/*
 * privateMessage.java
 *
 * Created on September 16, 2006, 7:44 PM
 *
 * Formats the incoming private message and hands it over to DBMSManager to
 * insert into the database.
 */

import java.io.*;

import javax.servlet.*;
import javax.servlet.http.*;


public class privateMessage extends HttpServlet {
    
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        //DBMSManager dbm= new DBMSManager(request.getParameter("db"));
        DBMSManager dbm = new DBMSManager();
        response.setContentType("text/plain");
        
        String comment = "";
        int uid = new Integer(request.getParameter("pvtuserid")).intValue();
        int cid = new Integer(request.getParameter("pvtchatid")).intValue();
        int tid = new Integer(request.getParameter("pvttargetid")).intValue();

        comment = request.getParameter("pvtcomment");
        
        dbm.AddPvtMessage(cid, uid, tid, comment);
        dbm.closeConnection();
    }
    
    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /** Handles the HTTP <code>GET</code> method.
     * @param request servlet request
     * @param response servlet response
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    }
    
    /** Handles the HTTP <code>POST</code> method.
     * @param request servlet request
     * @param response servlet response
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    }
    
    /** Returns a short description of the servlet.
     */
    public String getServletInfo() {
        return "Short description";
    }
    // </editor-fold>
}
